package com.yykj.tencent.im.server.controller;

import com.yykj.tencent.im.client.form.BatchSendSystemMsgRequest;
import com.yykj.tencent.im.client.form.SendCustomMsgRequest;
import com.yykj.tencent.im.server.bean.request.SendSystemMsgRequest;
import com.yykj.tencent.im.server.bean.response.SendMsgResult;
import com.yykj.tencent.im.server.service.SystemMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

@RestController
@Slf4j
@Api(tags = "腾讯云通信--系统消息")
@RequestMapping("api/tencent/im/system/message")
public class SystemMessageController {
    @Resource
    private SystemMessageService systemMessageService;

    @SneakyThrows
    @ApiOperation("发送系统消息")
    @PostMapping("/send")
    public SendMsgResult sendSystemMsg(@RequestBody SendSystemMsgRequest body){
        return systemMessageService.sendSystemMsg(body);
    }

    @ApiOperation("群发发送文本消息")
    @PostMapping("/batchSend")
    public SendMsgResult batchSendSystemMsg(@RequestBody @Valid BatchSendSystemMsgRequest body){
        return systemMessageService.batchSendSystemMsg(body);
    }

    @ApiOperation("群发发送自定义消息")
    @PostMapping("/batchSendCustomMsg")
    public SendMsgResult batchSendCustomMsg(@RequestBody @Valid BatchSendSystemMsgRequest body){
        return systemMessageService.batchSendCustomMsg(body);
    }

    @SneakyThrows
    @ApiOperation("群发自定义消息")
    @PostMapping("/sendCustomMsg")
    public List<SendMsgResult> sendCustomMsg(@RequestBody SendCustomMsgRequest sendCustomMsgRequest){
        return systemMessageService.sendCustomMsg(sendCustomMsgRequest);
    }


}
